from aredis import StrictRedis

from com.arcfox.util import constant


async def __open_client():
    return StrictRedis(host=constant.REDIS_HOST, port=constant.REDIS_PORT, db=constant.REDIS_DB,
                       password=constant.REDIS_PASSWORD)


def open_redis(func):
    async def wrapper(*a, **k):
        client = await __open_client()
        result = await func(*a, **k, client=client)
        return result

    return wrapper
